import java.sql.Array;
import java.util.Arrays;

public class MyBitSet {
    public byte[] elem;
    public int usedSize;
    public MyBitSet() {
        this.elem = new byte[1];
    }
    public MyBitSet(int n) {
        this.elem = new byte[n/8 +1];
    }
    public void set(int val) {
        if(val < 0) {
            throw new IndexOutOfBoundsException();
        }
        int arrayIndex = val / 8;
        int bitIndex = val % 8;
        if(arrayIndex > elem.length) {
            elem = Arrays.copyOf(elem,arrayIndex/8+1);
        }
        elem[arrayIndex] |= 1 << bitIndex;
        usedSize++;
    }
    public boolean get(int val) {
        if(val < 0) {
            throw new IndexOutOfBoundsException();
        }
        int arrayIndex = val / 8;
        int bitIndex = val % 8;

        if((elem[arrayIndex] & 1 << bitIndex) != 0) {
            return true;
        }
        return false;
    }

    public void remove(int val) {
        if(val < 0) {
            throw new IndexOutOfBoundsException();
        }
        int arrayIndex = val / 8;
        int bitIndex = val % 8;

        elem[arrayIndex] &= ~(1 << bitIndex);
        usedSize--;
    }

    public int getUsedSize() {
        return this.usedSize;
    }
}
